package com.burgeon.backend.SHOPBACKEND.controller;
/**
 * 套券
 */

import com.burgeon.backend.SHOPBACKEND.entity.couponGift.CouponGiftBean;
import com.burgeon.backend.SHOPBACKEND.entity.couponGift.CouponGiftItem;
import com.burgeon.backend.SHOPBACKEND.service.BackendCouponGiftService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("shopbackent/gift")
@RestController
@CrossOrigin
public class BackendCouponGiftController extends BaseController {

    @Autowired
    private BackendCouponGiftService backendCouponGiftService;

    @RequestMapping("createCoupon")
    public ResponseResult<Void> createCoupon(String id,String phone,String account){
        backendCouponGiftService.createCoupon(id,phone,account);
        return new ResponseResult<>(SUCCESS);
    }


    @RequestMapping("delCouponGiftItem")
    public ResponseResult<Void> delCouponGiftItem (String id) {
        backendCouponGiftService.delCouponGiftItem(id);
        return new ResponseResult<>(SUCCESS);
    }


    @RequestMapping("addCouponGift")
    public ResponseResult<Void> addCouponGift (String name, String account) {
        backendCouponGiftService.addCouponGift(name,account);
        return new ResponseResult<>(SUCCESS);
    }

    @RequestMapping("addCouponGiftItem")
    public ResponseResult<Void> addCouponGiftItem (String cid, String[] tids) {
        backendCouponGiftService.addCouponGiftItem(cid,tids);
        return new ResponseResult<>(SUCCESS);
    }



    @RequestMapping("list")
    public ResponseResult<List<CouponGiftBean>> list (String account) {
        List<CouponGiftBean> data = backendCouponGiftService.getList(account);
        return new ResponseResult<List<CouponGiftBean>>(SUCCESS,data);
    }

    @RequestMapping("itemList")
    public ResponseResult<List<CouponGiftItem>> itemList (String id) {
        List<CouponGiftItem> data = backendCouponGiftService.getItmeList(id);
        return new ResponseResult<List<CouponGiftItem>>(SUCCESS,data);
    }

    @RequestMapping("upItemCount")
    public ResponseResult<Void> upItemCount (String id, Integer count) {
        backendCouponGiftService.upItemCount(id,count);
        return new ResponseResult<>(SUCCESS);
    }


    /**
     * @author:
     * @description: 编辑修改套券是否展示等内容
     * @date: 2021/6/21 10:06
     * @param cid
     * @param name
     * @param integral
     * @param startDate
     * @param endDate
     * @param isShow
     * @return com.burgeon.backend.stsutil.ResponseResult<java.lang.Void>
     */
    @RequestMapping("upContent")
    public ResponseResult<Void> upContent(String cid,String name,Integer integral,String startDate,String endDate,String isShow){
        backendCouponGiftService.upContent(cid,name,integral,startDate,endDate,isShow);
        return new ResponseResult<>(SUCCESS);
    }

    /**
     * @author:
     * @description: 回显展示套券内容
     * @date: 2021/6/21 10:07
     * @param cid
     * @return com.burgeon.backend.stsutil.ResponseResult<com.burgeon.backend.SHOPBACKEND.entity.couponGift.CouponGiftItem>
     */
    @RequestMapping("showContent")
    public ResponseResult<CouponGiftBean> showContent(String cid){
        CouponGiftBean data = backendCouponGiftService.showContent(cid);
        return new ResponseResult<CouponGiftBean>(SUCCESS,data);
    }

}
